<!--
 * @Description: helloworld
 * @Author: zugelu
 * @Date: 2021-07-27 13:58:29
 * @LastEditors: zugelu
 * @LastEditTime: 2021-07-29 14:06:00
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="test1"></div>
</body>
<script src="../js/react.development.js"></script>
<script src="../js/react-dom.development.js"></script>
<script src="../js/babel.min.js"></script>

<script type="text/babel">
    class Person extends React.Component {
        myRef = React.createRef()

        showData = () => {
            console.log(this.myRef.current.value);
        }

        render() {
            return (
                <div>
                    <input ref={this.myRef} type="text" /> &nbsp; &nbsp;
                    <button onClick={this.showData}>按钮</button><br />
                </div>
            )
        }
    }

    ReactDOM.render(<Person name="Jack" age="20" sex="男" />, document.querySelector("#test1"))
</script>

</html>